from functools import reduce

# lambda表达式学习
computer = lambda x: x ** 2

print(computer(3))

# lambda结合内置函数使用
print(list(filter(lambda x: x > 3, (1, 2, 4, 3, 6, 5))))
print(list(map(lambda x, y: x + y, [1, 2, 4], [3, 6, 5])))
print(reduce(lambda x, y: x + y, [2, 3, 4], 1))

# 元组纵向转换，类似矩阵转换
"""
(1, 4)
(2, 5)
(3, 6)
"""
for z in zip((1, 2, 3), (4, 5, 6)):
    print(z)
# zip可以用来调换字典的key和value
dicta = {1: 'a', 2: 'b', 3: 'c'}
dictb = zip(dicta.values(), dicta.keys())
print(dict(dictb))
